package com.yang.article.controller.v1;

import com.yang.model.article.dtos.ArticleHomeDto;
import com.yang.model.common.dtos.ResponseResult;
import com.yang.common.constants.ArticleConstants;
import com.yang.article.service.ApArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
@Api(value = "app端文章列表", tags = "app_article", description = "app端文章列表API")
public class ArticleHomeController {


    @Autowired
    private ApArticleService apArticleService;

    @PostMapping("/load")
    @ApiOperation("加载文章列表")
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load2(dto, ArticleConstants.LOADTYPE_LOAD_MORE,true);
    }

    @PostMapping("/loadmore")
    @ApiOperation("加载更多文章列表")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return ResponseResult.okResult(apArticleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,dto));
    }

    @PostMapping("/loadnew")
    @ApiOperation("加载更新文章列表")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return ResponseResult.okResult(apArticleService.load(ArticleConstants.LOADTYPE_LOAD_NEW,dto));
    }
}